import { ColumnsType } from "antd/es/table"

import { generatePrefixVariables, getNumberValue, handleNumber } from "@/utils/util"

export const COLUMN_KEY_PREFIX = "bmhAccountManage_"

const useColumns = (newFormat: Function, getLabel: Function, getWidthWithCurrentLocale: Function) => {
	const columns: ColumnsType = [
		{
			key: "bmhName",
			dataIndex: "bmhName",
			align: "center",
			width: 240,
			title: newFormat("member.bmh_account"),
			render: (text: any, record: any) => record.bmhName || "-"
		},
		{
			key: "bmhId",
			dataIndex: "bmhId",
			align: "center",
			width: 240,
			title: newFormat("member.bmh_id"),
			render: (text: any, record: any) => record.bmhId || "-"
		},
		{
			key: "blacklistStatus",
			dataIndex: "blacklistStatus",
			align: "center",
			width: 150,
			title: newFormat("common.components.black_status"),
			render: (text: any, record: any) => (
				<span className={record.blacklistStatus === 0 ? "disableRgba" : "normalRgba"}>
					{getLabel(record.blacklistStatus, "blackStatusType", false)}
				</span>
			)
		},
		{
			key: "bindStatus",
			dataIndex: "bindStatus",
			align: "center",
			width: 210,
			title: newFormat("common.components.binding_status"),
			render: (text: any, record: any) => (
				<span className={record.bindStatus === 0 ? "disableRgba" : "normalRgba"}>
					{getLabel(record.bindStatus, "bindStatusType", false)}
				</span>
			)
		},
		{
			key: "windControlName",
			dataIndex: "windControlName",
			align: "center",
			width: 150,
			title: newFormat("common.risk_control_level"),
			render: (text: any, record: any) => record.windControlName || "-"
		},
		{
			key: "bindNum",
			dataIndex: "bindNum",
			align: "center",
			width: 180,
			title: newFormat("common.components.bind_count"),
			render: (text: any, record: any) => record.bindNum
		},
		{
			key: "userName",
			dataIndex: "userName",
			align: "center",
			width: 150,
			title: (
				<>
					{newFormat("member.current_user_uame")}
					<br />
					{newFormat("common.components.member_name")}
				</>
			),
			render: (text: any, record: any) => (
				<>
					<span>{record.userName || "-"}</span>
					<br />
					<span>{record.realName || "-"}</span>
				</>
			)
		},
		{
			key: "withdrawalSuccessNum",
			dataIndex: "withdrawalSuccessNum",
			align: "center",
			width: getWidthWithCurrentLocale(140, 2.5),
			title: (
				<>
					{newFormat("member.members_successful_withdrawals")}
					<br />
					{newFormat("member.members_rejected_withdrawals")}
				</>
			),
			render: (text: any, record: any) => (
				<>
					<span>{getNumberValue(record.withdrawalSuccessNum)}</span>
					<br />
					<span>{getNumberValue(record.withdrawalFailNum)}</span>
				</>
			)
		},
		{
			key: "withdrawalTotalAmount",
			dataIndex: "withdrawalTotalAmount",
			align: "center",
			width: 200,
			title: newFormat("member.members_total_amount"),
			render: (text: any, record: any) => handleNumber(record.currency, record.withdrawalTotalAmount)
		},
		{
			key: "proxyWithdrawalSuccessNum",
			dataIndex: "proxyWithdrawalSuccessNum",
			align: "center",
			width: getWidthWithCurrentLocale(140, 2.5),
			title: (
				<>
					{newFormat("member.agent_successful_withdrawals")}
					<br />
					{newFormat("member.agent_rejected_withdrawals")}
				</>
			),
			render: (text: any, record: any) => (
				<>
					<span>{getNumberValue(record.proxyWithdrawalSuccessNum)}</span>
					<br />
					<span>{getNumberValue(record.proxyWithdrawalFailNum)}</span>
				</>
			)
		},
		{
			key: "proxyTotalAmount",
			dataIndex: "proxyTotalAmount",
			align: "center",
			width: 200,
			title: newFormat("member.agent_total_amount"),
			render: (text: any, record: any) => handleNumber(record.currency, record.proxyTotalAmount)
		},
		{
			key: "createdAt",
			dataIndex: "createdAt",
			align: "center",
			width: 160,
			title: newFormat("member.bmh_account_new_time"),
			render: (text: any, record: any) => record.createdAt || "-"
		},
		{
			key: "lastWithdrawalTime",
			dataIndex: "lastWithdrawalTime",
			align: "center",
			width: 160,
			title: newFormat("member.last_withdrawal_time"),
			render: (text: any, record: any) => record.lastWithdrawalTime || "-"
		},
		{
			key: "updatedBy",
			dataIndex: "updatedBy",
			align: "center",
			width: 220,
			title: (
				<>
					{newFormat("common.last_updateBy")}
					<br />
					{newFormat("common.last_updateAt")}
				</>
			),
			render: (text: any, record: any) => (
				<>
					<span>{record.updatedBy || "-"}</span>
					<br />
					<span>{record.updatedAt || "-"}</span>
				</>
			)
		}
	]

	return generatePrefixVariables(columns, COLUMN_KEY_PREFIX)
}

export default useColumns
